package com.win.autowired.controller;

import com.win.autowired.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
//  1.属性注入
//    @Autowired
    private UserService userService;

//    2.set注入
//    private UserService userService;
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

//    3.构造器注入
//    private UserService userService;
//
//    @Autowired
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }


//    4.形参注入
//     private UserService userService;
//
//    public UserController(@Autowired UserService userService) {
//        this.userService = userService;
//    }


    public UserController(UserService userService) {
        this.userService = userService;
    }

    public void show(){
        userService.add();
        System.out.println("Controller层执行结束");
    }
}
